import request from '@/utils/request'

// 登录函数
/**
 * @description: 登录函数
 * @param {*} data { mobile,password}
 * @return {*} promise
 */
export function loginAPI(data) {
  return request({
    url: '/user/login',
    method: 'POST',
    data
  })
}
/**
 * @description: 获取用户权限信息
 * @param {*} data {}
 * @return {*} promise
 */
export function getProfileAPI() {
  return request({
    url: '/user/permissions',
    method: 'GET'
  })
}
/**
 * 退出登录
 * @returns 
 */
export function logoutAPI() {
  return request({
    url: '/user/logout',
    method: 'POST'
  })
}

export function getAllUsersByPageAPI(params) {
  return request({
    url: '/user/getAllUsersByPage',
    params
  })
}
export function exportExcelAPI(params) {
  return request({
    url: '/user/exportExcel',
    method: 'GET',
    responseType: 'blob', 
    params
  });
}

export function addOrEditUserAPI(grade) {
  return request({
    url: '/user/addOrEditUser',
    method: 'post',
    data: grade
  })
}

export function deleteUserAPI(userId){
  return request({
    url:`/user/deleteUser/${userId}`,
    method: 'delete'
  })
}

export function getAllTeachersAPI() {
  return request({
    url: '/user/getAllTeachers',
  })
}

export function getUserInfoAPI() {
  return request({
    url: '/user/getUserInfo',
  })
}

export function changePasswordAPI(password){
  return request({
    url:`/user/changePassword/${password}`,
    method: 'delete'
  })
}